package com.cuit.food.food.Ycontronller;

import Api.userinfsearch.userinfosearch;
import com.cuit.food.food.Ycommen.SearchOp;
import com.cuit.food.food.Yservice.pageinfoservice;
import common.result.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class controller implements userinfosearch {

    @Autowired
    pageinfoservice page;

    @Override
    @GetMapping("/FindResByPriceAndtype")
    public ResponseResult FindResByPriceAndtype(@RequestParam(value = "typename", required = true) String typename,
                                                @RequestParam(value = "price", required = true)long price,
                                                @RequestParam(value = "longitude", required = true)double longitude,
                                                @RequestParam(value = "latitude", required = true)double latitude) {
        return page.FindResByPriceAndType(typename, price, longitude, latitude,  SearchOp.RANDOM.getFlag());
    }

    @Override
    @GetMapping("/FindResByPriceAndtypeAndSort")
    public ResponseResult FindResByPriceAndtypeAndSort(@RequestParam(value = "typename", required = true) String typename,
                                                       @RequestParam(value = "price", required = true)long price,
                                                       @RequestParam(value = "longitude", required = true)double longitude,
                                                       @RequestParam(value = "latitude", required = true)double latitude){
        return page.FindResByPriceAndType(typename, price, longitude, latitude,  SearchOp.ORDERED.getFlag());
    }

    @Override
    @GetMapping("/FindResRank")
    public ResponseResult FindResByFoodType(
            @RequestParam(value = "typename", required = false, defaultValue = "总榜") String typename,
            @RequestParam(value = "longitude") double longitude,
            @RequestParam(value = "latitude") double latitude
    )
    {
        //查找所有小于10000000的饭店，并且按照得到星的数量排序
    return page.FindResByPriceAndType(typename, 10000000, longitude, latitude,  SearchOp.START.getFlag());

    }
}